/**
 * 
 */
package com.td.framework.webmanager.qxgl.action;

import java.util.ArrayList;
import java.util.List;

import com.td.framework.common.AbstractAction;
import com.td.framework.webmanager.domain.AppsysQxfwjlgx;
import com.td.framework.webmanager.domain.AppsysQxygns;
import com.td.framework.webmanager.domain.AppsysYmgnBean;
import com.td.framework.webmanager.domain.AppsysYmxzfwjlBean;
import com.td.framework.webmanager.domain.YmxztjBean;
import com.td.framework.webmanager.qxgl.service.QxglService;
import com.opensymphony.xwork2.Action;

/**
 * 
 *  Title:
 *  Description: 
 *  Copyright: Copyright (c) 2008 
 *  Company 北京水软科技有限公司
 * @version 1.0
 */
public class QxglAction extends AbstractAction implements Action {

	private static final long serialVersionUID = 1L;
	private String yhbhs = "";//用户编号数;
	private String yhzbh ="";//用户组编号
	private String target = "";//返回参数;
	private QxglService qxglService = null;// 权限处理业务层接口;
	private String sysTreeXml = "";// 系统权限树xml字符流;
	private String yhzTreeXml = "";// 用户当前系统权限树xml字符流;
	private String[] ymbhs = null;//页面编号,授权时用;
	private String urlFlag = "";//区分字段,授权是区分是点击下一步还是完成;
	private List<AppsysQxygns>  rightTreeList = null;//用户组当前权限List;
	private List<AppsysYmgnBean> appsysYmgnBeanList = null;//页面功能List;
	private List<AppsysYmgnBean> xzzdList = null;// 限制字段List;
	private List<AppsysYmxzfwjlBean> fwjlList = null;//限制访问记录List;
	private List<AppsysQxfwjlgx> qxfwjlgxs = null;//权限与限制访问记录关系数组;
	private List<YmxztjBean> ymxztjList = null;//限制条件List;
	private String xzbh = "";//限制编号,选择条件用;
	private String qxbh = "";//权限编号;
	private String [] gnbhs = null;//功能编号与权限标志组合数组;

	/**
	 * @toDo:生成授权所需的Xml字符流;（当前只考虑用户组层次，没有考虑用户）
	 * @return target;
	 */
	public String createXmlTree() {
		sysTreeXml = qxglService.getCurrentTreeXml("system", yhzbh,0L, 1);
		yhzTreeXml = qxglService.getCurrentTreeXml("my", yhzbh,0L, 0);
		target = "rightTree";
		return target;
	}
	/**
	 * @toDo:用户系统授权保存;
	 * @return target;
	 */
	public String  changeRight()
	{
		boolean flag = qxglService.addAppsysQxxx(yhzbh, ymbhs);
		if(flag)
		{
			target = "changeSuccess";
			if(urlFlag.equals("next")&&ymbhs!=null)
			{
				target="nextRight";
			}
		}
		else
		{
			target = "changeFailure";
		}
		return target;
	}
	
	/**
	 * @toDo:生成用户组当前权限树;
	 * @return target;
	 */
	public String  createRightTree()
	{
		rightTreeList = qxglService.getRightTreeList(ymbhs);
		qxbh=qxglService.getQxbh(yhbhs);
		target = "rightTree";
		return target;
	}
	/**
	 * @toDo:生成页面级功能页面
	 * @return target;
	 */
	@SuppressWarnings("unchecked")
	public String createYmgns()
	{
		appsysYmgnBeanList = new ArrayList();
		xzzdList = new ArrayList();
		if(qxbh!=null&&ymbhs!=null)
		{
			appsysYmgnBeanList=qxglService.findAppsysYmgnBean(new Long(-1), ymbhs[0],1);
			xzzdList = qxglService.findAppsysYmgnBean(new Long(-1), ymbhs[0],2);
			fwjlList = qxglService.findAppsysYmxzfwjlBean(new Long(-1), ymbhs[0]);
		}
		target = "ymgns";
		return target;
	}
	/**
	 * @toDo:用户组页面级功能授权保存;
	 * @return target;
	 */
	public String  changeYmgnRight()
	{
		
		if(qxglService.addYmgnRight(qxbh, ymbhs[0], gnbhs,qxfwjlgxs))
		{
			this.handleMessage("info", "授权成功,请继续操作!");
			target = "changeSuccess";
		}
		else
		{
			this.handleMessage("info", "授权失败,请重新操作!");
			target = "changeFailure";
		}
		appsysYmgnBeanList=qxglService.findAppsysYmgnBean(new Long(-1), "-1",1);
		xzzdList = qxglService.findAppsysYmgnBean(new Long(-1), ymbhs[0],2);
		fwjlList = qxglService.findAppsysYmxzfwjlBean(new Long(-1), ymbhs[0]);
		return target;
	}
	/**
	 * @toDo:get
	 * @return the yhbhs
	 */
	public String getYhbhs() {
		return yhbhs;
	}
	/**
	 * @toDo:set
	 * @param yhbhs the yhbhs to set
	 */
	public void setYhbhs(String yhbhs) {
		this.yhbhs = yhbhs;
	}
	/**
	 * @toDo:get
	 * @return the target
	 */
	public String getTarget() {
		return target;
	}
	/**
	 * @toDo:set
	 * @param target the target to set
	 */
	public void setTarget(String target) {
		this.target = target;
	}
	/**
	 * @toDo:get
	 * @return the sysTreeXml
	 */
	public String getSysTreeXml() {
		return sysTreeXml;
	}
	/**
	 * @toDo:set
	 * @param sysTreeXml the sysTreeXml to set
	 */
	public void setSysTreeXml(String sysTreeXml) {
		this.sysTreeXml = sysTreeXml;
	}
	/**
	 * @toDo:get
	 * @return the yhzTreeXml
	 */
	public String getYhzTreeXml() {
		return yhzTreeXml;
	}
	/**
	 * @toDo:set
	 * @param yhzTreeXml the yhzTreeXml to set
	 */
	public void setYhzTreeXml(String yhzTreeXml) {
		this.yhzTreeXml = yhzTreeXml;
	}
	/**
	 * @toDo:get
	 * @return the ymbhs
	 */
	public String[] getYmbhs() {
		return ymbhs;
	}
	/**
	 * @toDo:set
	 * @param ymbhs the ymbhs to set
	 */
	public void setYmbhs(String[] ymbhs) {
		this.ymbhs = ymbhs;
	}
	/**
	 * @toDo:get
	 * @return the urlFlag
	 */
	public String getUrlFlag() {
		return urlFlag;
	}
	/**
	 * @toDo:set
	 * @param urlFlag the urlFlag to set
	 */
	public void setUrlFlag(String urlFlag) {
		this.urlFlag = urlFlag;
	}
	/**
	 * @toDo:get
	 * @return the rightTreeList
	 */
	public List<AppsysQxygns> getRightTreeList() {
		return rightTreeList;
	}
	/**
	 * @toDo:set
	 * @param rightTreeList the rightTreeList to set
	 */
	public void setRightTreeList(List<AppsysQxygns> rightTreeList) {
		this.rightTreeList = rightTreeList;
	}
	/**
	 * @toDo:get
	 * @return the appsysYmgnBeanList
	 */
	public List<AppsysYmgnBean> getAppsysYmgnBeanList() {
		return appsysYmgnBeanList;
	}
	/**
	 * @toDo:set
	 * @param appsysYmgnBeanList the appsysYmgnBeanList to set
	 */
	public void setAppsysYmgnBeanList(List<AppsysYmgnBean> appsysYmgnBeanList) {
		this.appsysYmgnBeanList = appsysYmgnBeanList;
	}
	/**
	 * @toDo:get
	 * @return the qxbh
	 */
	public String getQxbh() {
		return qxbh;
	}
	/**
	 * @toDo:set
	 * @param qxbh the qxbh to set
	 */
	public void setQxbh(String qxbh) {
		this.qxbh = qxbh;
	}
	/**
	 * @toDo:get
	 * @return the gnbhs
	 */
	public String[] getGnbhs() {
		return gnbhs;
	}
	/**
	 * @toDo:set
	 * @param gnbhs the gnbhs to set
	 */
	public void setGnbhs(String[] gnbhs) {
		this.gnbhs = gnbhs;
	}
	/**
	 * toDo:get
	 * @return xzzdList
	 */
	public List<AppsysYmgnBean> getXzzdList() {
		return xzzdList;
	}
	/**
	 * toDo:set
	 * @param xzzdList 
	 */
	public void setXzzdList(List<AppsysYmgnBean> xzzdList) {
		this.xzzdList = xzzdList;
	}
	/**
	 * @return the fwjlList
	 */
	public List<AppsysYmxzfwjlBean> getFwjlList() {
		return fwjlList;
	}
	/**
	 * @param fwjlList the fwjlList to set
	 */
	public void setFwjlList(List<AppsysYmxzfwjlBean> fwjlList) {
		this.fwjlList = fwjlList;
	}
	/**
	 * @return the qxfwjlgxs
	 */
	public List<AppsysQxfwjlgx> getQxfwjlgxs() {
		return qxfwjlgxs;
	}
	/**
	 * @param qxfwjlgxs the qxfwjlgxs to set
	 */
	public void setQxfwjlgxs(List<AppsysQxfwjlgx> qxfwjlgxs) {
		this.qxfwjlgxs = qxfwjlgxs;
	}
	/**
	 * @return the ymxztjList
	 */
	public List<YmxztjBean> getYmxztjList() {
		return ymxztjList;
	}
	/**
	 * @param ymxztjList the ymxztjList to set
	 */
	public void setYmxztjList(List<YmxztjBean> ymxztjList) {
		this.ymxztjList = ymxztjList;
	}
	/**
	 * @return the xzbh
	 */
	public String getXzbh() {
		return xzbh;
	}
	/**
	 * @param xzbh the xzbh to set
	 */
	public void setXzbh(String xzbh) {
		this.xzbh = xzbh;
	}
	public QxglService getQxglService() {
		return qxglService;
	}
	public void setQxglService(QxglService qxglService) {
		this.qxglService = qxglService;
	}
	public String getYhzbh() {
		return yhzbh;
	}
	public void setYhzbh(String yhzbh) {
		this.yhzbh = yhzbh;
	}
	
}
